package com.hf.wujian.dispatch.imp;

import com.hf.wujian.annotation.Dispatch;
import com.hf.wujian.constant.Command;
import com.hf.wujian.dispatch.BSHDispatch;
import com.hf.wujian.model.GameHall;
import com.hf.wujian.model.GameUser;
import com.hf.wujian.netty.NettyMsg;
import io.netty.channel.ChannelHandlerContext;

import java.util.Map;

/**
 * 创建房间调度类
 *
 * @author hf
 * @date 2018/11/23
 * @version 1.0
 *
 */
@Dispatch(command = Command.COMMAND_CREATEGAMEROOM)
public class CreateRoomDispatch implements BSHDispatch{

    @Override
    public void dispatch(ChannelHandlerContext ctx, NettyMsg nettyMsg, GameHall gameHall, GameUser gameUser) {
        Map<String,Object> data = nettyMsg.getData();
        String roomName = (String) data.get("roomName");
        if(roomName == null && roomName.equals("")){
            return;
        }
        gameHall.createGameRoom(gameUser.getUuid(),roomName,ctx);
    }
}
